Skip to content

fix: preserve staked balances on Accounts API updates - #9753

Merged
salimtb merged 4 commits into
mainfrom
fix/preserve-staked-balance-accounts-api
Aug 6, 2026
Merged

fix: preserve staked balances on Accounts API updates#9753
salimtb merged 4 commits into
mainfrom
fix/preserve-staked-balance-accounts-api

Conversation

@salimtb

@salimtb salimtb commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Exclude staking vault asset IDs from Accounts API v5/v6 balance processing and keep prior staked amounts when replaceCoveredChainBalances would drop them, so network switches no longer reset pooled staking to missing/0.

UI PR: MetaMask/metamask-mobile#34178

Explanation

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes balance merge behavior for staking contract assets across Accounts API and covered-chain replacement; scope is narrow but affects displayed staked ETH totals users rely on.

Overview
Fixes pooled staking balances disappearing when Accounts API refreshes chain slices (e.g. network switch or replaceCoveredChainBalances).

Accounts API path: v5 and v6 balance parsing now skips staking vault contract asset IDs via isStakingContractAssetId, so API rows that treat the vault share token as a normal ERC-20 (often 0 or stale) no longer merge into assetsBalance and overwrite StakedBalanceDataSource amounts.

Merge replace path: When a merge update uses replaceCoveredChainBalances and the payload omits staking contract assets, AssetsController copies prior staked balances from state instead of clearing them with other covered-chain tokens.

Tests cover API exclusion (v5/v6) and preservation on Accounts API merge replace.

Reviewed by Cursor Bugbot for commit 949c836. Bugbot is set up for automated code reviews on this repo. Configure here.

salimtb added a commit that referenced this pull request Aug 3, 2026
…eased

The entry was mistakenly placed in the released 11.3.0 section; move it
under Unreleased and add the PR link (#9753).

Co-authored-by: Cursor <cursoragent@cursor.com>
salimtb added a commit that referenced this pull request Aug 3, 2026
…eased

The entry was mistakenly placed in the released 11.3.0 section; move it
under Unreleased and add the PR link (#9753).

Co-authored-by: Cursor <cursoragent@cursor.com>
@salimtb
salimtb force-pushed the fix/preserve-staked-balance-accounts-api branch from 866dfb4 to 6a9595c Compare August 3, 2026 08:14
@salimtb
salimtb marked this pull request as ready for review August 5, 2026 17:10
@salimtb
salimtb requested review from a team as code owners August 5, 2026 17:10
@salimtb
salimtb temporarily deployed to default-branch August 5, 2026 17:10 — with GitHub Actions Inactive
bergarces
bergarces previously approved these changes Aug 5, 2026
@salimtb
salimtb added this pull request to the merge queue Aug 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 5, 2026
@salimtb
salimtb added this pull request to the merge queue Aug 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 6, 2026
salimtb and others added 4 commits August 6, 2026 13:45
Exclude staking vault asset IDs from Accounts API v5/v6 balance processing
and keep prior staked amounts when replaceCoveredChainBalances would drop
them, so network switches no longer reset pooled staking to missing/0.

Co-authored-by: Cursor <cursoragent@cursor.com>
…eased

The entry was mistakenly placed in the released 11.3.0 section; move it
under Unreleased and add the PR link (#9753).

Co-authored-by: Cursor <cursoragent@cursor.com>
…ource test

Co-authored-by: Cursor <cursoragent@cursor.com>
…eased after rebase

Co-authored-by: Cursor <cursoragent@cursor.com>
@salimtb
salimtb force-pushed the fix/preserve-staked-balance-accounts-api branch from f2f73c1 to 949c836 Compare August 6, 2026 11:46
@salimtb
salimtb enabled auto-merge August 6, 2026 11:50
@salimtb
salimtb added this pull request to the merge queue Aug 6, 2026
Merged via the queue into main with commit f7a4228 Aug 6, 2026
58 checks passed
@salimtb
salimtb deleted the fix/preserve-staked-balance-accounts-api branch August 6, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants